package edu.hcnu.service.impl;

import edu.hcnu.domain.entity.YiQing;
import edu.hcnu.mapper.YiQingMapper;
import edu.hcnu.service.IYiQingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: Administrator
 * @time: 2023/2/9 23:52
 */
@Service
public class YiQingServiceImpl implements IYiQingService {

    @Autowired
    private YiQingMapper mapper;

    @Override
    public List<YiQing> queryPage(int current, int size, String key) {
        return mapper.queryPage((current - 1) * size, size, key);
    }

    @Override
    public Boolean add(YiQing yiQing) {
        if (yiQing.getId() != null) {
            return mapper.updateYiQing(yiQing);
        }
        return mapper.insertYiQing(yiQing);
    }

    @Override
    public Boolean deleteById(int id) {
        return mapper.deleteById(id);
    }

    @Override
    public Integer count(String key) {
        return mapper.count(key);
    }
}
